import router from './index'
import useUserStore from '@/store/modules/userStore'

export default function installGuard(router:any) {
  router.beforeEach((to, from,next) => {

    let userStore = useUserStore()
    if(userStore.token){
      if(to.path == '/login'){
        return next('/home')
      }else{
        return next()
      }
    }else{
      if(to.path == '/login'){
        return next()
      }else{
        return next('/login')
   
      }
    }
  })
  
  
  
  
  router.afterEach((to, from) => {
    
  })                                                                               

}